using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ACME.Northwind.DataTransfer;
using ACME.Northwind.Service.Interfaces;
using ACME.Northwind.MockProxy.EventArgs;

namespace ACME.Northwind.MockProxy
{
	/// <summary>
	/// The service implementation for Shipper object
	/// </summary>
	public partial class ShipperService : IShipperService
	{
		#region IShipperService Members

		/// <summary>
		/// Run the mock for the select by the primary key
		/// </summary>
		public ShipperDTO SelectByPrimaryKey(int shipperid)
		{
			ShipperPrimaryKeyEventArgs eventArgs = new ShipperPrimaryKeyEventArgs(shipperid);
			this.OnMockShipperSelectByPrimaryKey(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Run the mock for select all
		/// </summary>
		public List<ShipperDTO> RunSelect()
		{
			ShipperRunSelectEventArgs eventArgs = new ShipperRunSelectEventArgs();
			this.OnMockShipperRunSelect(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Run the mock for select with LINQ
		/// </summary>
		public List<ShipperDTO> RunSelect(string linq)
		{
			ShipperRunSelectLINQEventArgs eventArgs = new ShipperRunSelectLINQEventArgs(linq);
			this.OnMockShipperRunSelectLINQ(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Run the mock for paged select
		/// </summary>
		public PagedQueryResults<ShipperDTO> RunSelect(int pageIndex, int pageSize, bool ascending, string sortColumn, string linq)
		{
			ShipperRunSelectPagedEventArgs eventArgs = new ShipperRunSelectPagedEventArgs(pageIndex, pageSize, ascending, sortColumn, linq);
			this.OnMockShipperRunSelectPaged(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Return a list of related Order objects
		/// </summary>
		public List<OrderDTO> GetOrderList(ShipperDTO item)
		{
			ShipperDTOEventArgs eventArgs = new ShipperDTOEventArgs(item);
			this.OnMockGetOrderList(eventArgs);
			List<OrderDTO> retval = new List<OrderDTO>();
			retval.AddRange(eventArgs.ReturnDTOList.Select(x => (OrderDTO)x));
			return retval;
		}

		/// <summary>
		/// Persists a single item
		/// </summary>
		public bool Persist(ShipperDTO dto)
		{
			ShipperPersistEventArgs eventArgs = new ShipperPersistEventArgs(dto);
			this.OnMockShipperPersist(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Persists a list
		/// </summary>
		public bool Persist(List<ShipperDTO> list)
		{
			ShipperPersistEventArgs eventArgs = new ShipperPersistEventArgs(list);
			this.OnMockShipperPersist(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Delete a single item
		/// </summary>
		public bool Delete(ShipperDTO dto)
		{
			ShipperDeleteEventArgs eventArgs = new ShipperDeleteEventArgs(dto);
			this.OnMockShipperDelete(eventArgs);
			return eventArgs.ReturnValue;
		}

		#endregion

		#region Shipper Events

		partial void GetSelectByPrimaryKey();

		/// <summary>
		/// The event for the SelectByPrimaryKey method
		/// </summary>
		public event EventHandler<ShipperPrimaryKeyEventArgs> MockShipperSelectByPrimaryKey;

		/// <summary>
		/// Raises the OnMockRegistrationCodeSelectByPrimaryKey event
		/// </summary>
		protected virtual void OnMockShipperSelectByPrimaryKey(ShipperPrimaryKeyEventArgs e)
		{
			if (this.MockShipperSelectByPrimaryKey != null)
				this.MockShipperSelectByPrimaryKey(this, e);
		}

		/// <summary>
		/// The event for the RunSelect method
		/// </summary>
		public event EventHandler<ShipperRunSelectEventArgs> MockShipperRunSelect;

		/// <summary>
		/// Raises the OnMockRunSelect event
		/// </summary>
		protected virtual void OnMockShipperRunSelect(ShipperRunSelectEventArgs e)
		{
			if (this.MockShipperRunSelect != null)
				this.MockShipperRunSelect(this, e);
		}

		/// <summary>
		/// The event for the RunSelectLINQ method
		/// </summary>
		public event EventHandler<ShipperRunSelectLINQEventArgs> MockShipperRunSelectLINQ;

		/// <summary>
		/// The event for the OnMockRunSelectLINQ method
		/// </summary>
		protected virtual void OnMockShipperRunSelectLINQ(ShipperRunSelectLINQEventArgs e)
		{
			if (this.MockShipperRunSelectLINQ != null)
				this.MockShipperRunSelectLINQ(this, e);
		}

		/// <summary>
		/// The event for the RunSelectPaged method
		/// </summary>
		public event EventHandler<ShipperRunSelectPagedEventArgs> MockShipperRunSelectPaged;

		/// <summary>
		/// The event for the OnMockRunSelectPaged method
		/// </summary>
		protected virtual void OnMockShipperRunSelectPaged(ShipperRunSelectPagedEventArgs e)
		{
			if (this.MockShipperRunSelectPaged != null)
				this.MockShipperRunSelectPaged(this, e);
		}

		/// <summary>
		/// The event for the GetOrderList method
		/// </summary>
		public event EventHandler<ShipperDTOEventArgs> MockGetOrderList;

		/// <summary>
		/// The event for the OnMockGetOrderList method
		/// </summary>
		protected virtual void OnMockGetOrderList(ShipperDTOEventArgs e)
		{
			if (this.MockGetOrderList != null)
				this.MockGetOrderList(this, e);
		}

		/// <summary>
		/// The event for the Persist method
		/// </summary>
		public event EventHandler<ShipperPersistEventArgs> MockShipperPersist;

		/// <summary>
		/// Raises the OnMockPersist event
		/// </summary>
		protected virtual void OnMockShipperPersist(ShipperPersistEventArgs e)
		{
			if (this.MockShipperPersist != null)
				this.MockShipperPersist(this, e);
		}

		/// <summary>
		/// The event for the Delete method
		/// </summary>
		public event EventHandler<ShipperDeleteEventArgs> MockShipperDelete;

		/// <summary>
		/// Raises the OnMockDelete event
		/// </summary>
		protected virtual void OnMockShipperDelete(ShipperDeleteEventArgs e)
		{
			if (this.MockShipperDelete != null)
				this.MockShipperDelete(this, e);
		}

		#endregion

	}
}
